<?php

namespace campus\controllers;

use common\models\Running;
use common\models\service\RunningService;
use common\models\Water;
use Yii;

class RunningController extends BaseController
{
    public function init()
    {
        parent::init();
        $this->model = Running::className();
    }

    public function actionIndex()
    {
        if (Yii::$app->request->isPost){
            $data = RunningService::getList($this->campus_id,[['review_status','in',[1,2]]]);
            return $data;
        }
        return parent::actionIndex();
    }

    public function actionWait()
    {
        if (Yii::$app->request->isPost){
            $data = RunningService::getList($this->campus_id,[['review_status','in',[0]]]);
            return $data;
        }
        return parent::actionIndex();
    }

    public function actionReview()
    {
        if (Yii::$app->request->isPost){
            $post = Yii::$app->request->post();
            return RunningService::review($post);
        }
        $data = RunningService::review([]);
        return $this->render('',$data);
    }

    public function actionWater()
    {
        $this->model = Water::className();
        if (Yii::$app->request->isPost){
            return parent::actionIndex(true,[['fund_type','in',[1]]]);
        }
        return parent::actionIndex();
    }
}